import java.util.Random;
import java.util.Scanner;

/**
 * @program: javase
 * @description: 剪刀石头布
 * @author: lld
 * @create: 2020/08/27 08:16
 **/
public class Game {
    public static void main(String[] args) {
        String isEnd = "n";
        int count1 = 0;
        int count2 = 0;
        Scanner scanner = new Scanner(System.in);
        User user = new User();
        Computer computer = new Computer();
        DoGame doGame = new DoGame();
        doGame.init();
        int i = scanner.nextInt();
        String s = doGame.startGame(i);
        System.out.println("你选择了" + s + "对战");
        int count = doGame.getCount();
        do {
            count++;
            System.out.print("请出拳");
            int i1 = scanner.nextInt();
            String play = user.play(i1);
            System.out.println("你出拳是：" + play);
            String play1 = computer.play();
            System.out.println("电脑出拳是：" + play1);

            System.out.print("结果：");
            if (play.equals(play1)) {
                System.out.println("你们是平局");
            } else if ((play.equals("剪刀") && play1.equals("布")) || (play.equals("石头") && play1.equals("剪刀")) || (play.equals("布") && play1.equals("石头"))) {
                System.out.println("恭喜你，你战胜了" + s);
                count1++;
            } else {
                System.out.println("很遗憾，" + s + "战胜了你");
                count2++;
            }
            System.out.println("是否继续(y/n)?");
            isEnd = scanner.next();
        } while (isEnd.equals("y"));
        if (!isEnd.equals("y")) {
            doGame.showResult(s, count, count1, count2);
        }
    }
}

class User {
    private String userName;
    private int score;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    public String play(int i) {

        if (i == 1) {
            return "剪刀";
        } else if (i == 2) {
            return "石头";
        } else if (i == 3) {
            return "布";
        } else {
            return "输入有误";
        }
    }
}

class Computer {
    private String name;
    private int score;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    public String play() {
        int i = new Random().nextInt(3) + 1;
        if (i == 1) {
            return "剪刀";
        } else if (i == 2) {
            return "石头";
        } else if (i == 3) {
            return "布";
        } else {
            return "输入有误";
        }
    }
}

class DoGame {
    private User user;
    private Computer computer;
    private int count = 0;

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Computer getComputer() {
        return computer;
    }

    public void setComputer(Computer computer) {
        this.computer = computer;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public void init() {
        user = new User();
        computer = new Computer();
        System.out.println("**********欢迎来到猜拳游戏**********");
        System.out.println("出拳规则 ：1.剪刀，2.石头，3.布");
        System.out.print("请选择对方角色：1.刘备，2.曹操，3.孙权 ");
    }

    public String startGame(int i) {
        if (i == 1) {
            return "刘备";
        } else if (i == 2) {
            return "曹操";
        } else if (i == 3) {
            return "孙权";
        } else {
            return "输入有误";
        }
    }

    public void showResult(String s, int count, int count1, int count2) {
        System.out.println("你  VS  " + s);
        System.out.println("对战次数：" + count);
        System.out.println("你赢次数：" + count1);
        System.out.println(s + "赢次数：" + count2);
        if (count1 == count2) {
            System.out.println("你们势均力敌");
        } else if (count1 > count2) {
            System.out.println("你更牛逼");
        } else {
            System.out.println(s + "更牛逼");
        }

    }
}
